﻿using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace socialnetworkApp.Core.Timer
{
    using System;
    using System.Timers;

    public class TimerHelper
    {
        private Timer timer;
        private Action callback;

        public TimerHelper(int interval, Action callback)
        {
            this.timer = new Timer(interval);
            this.callback = callback;
            this.timer.Elapsed += (sender, e) => RunTimerCallback();
        }

        private void RunTimerCallback()
        {
            callback?.Invoke();
        }

        public void Start()
        {
            timer.Start();
        }

        public void Stop()
        {
            timer.Stop();
        }
    }
}
